﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web;

namespace Business.AID.Extensions
{
    public static class Popup
    {
        public static void AjaxRedirect(string url, System.Web.UI.Page page)
        {
            string _script = "<script>function popup(url) { var width = 510; var height = 144; var left = (screen.width - width) / 2;var top = (screen.height - height) / 2;var params = 'width=' + width + ', height=' + height;params += ', top=' + top + ', left=' + left;params += ', directories=no';params += ', location=no';params += ', menubar=no';params += ', resizable=no';params += ', scrollbars=no';params += ', status=no';params += ', toolbar=no';newwin = window.open(url, 'windowname5', params);if (window.focus) { newwin.focus() }return false; } popup('" + url + "')</script>";

            if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("window.open"))
            {
                page.ClientScript.RegisterStartupScript(typeof(Popup), "RedirectTo", _script);
            }

        }
        public static void AjaxRedirect(string url, System.Web.UI.Page page, int width, int height)
        {
            string _script = "<script>function popup(url) { var width = " + width + "; var height = " + height + "; var left = (screen.width - width) / 2;var top = (screen.height - height) / 2;var params = 'width=' + width + ', height=' + height;params += ', top=' + top + ', left=' + left;params += ', directories=no';params += ', location=no';params += ', menubar=no';params += ', resizable=no';params += ', scrollbars=yes';params += ', status=no';params += ', toolbar=no';newwin = window.open(url, 'windowname5', params);if (window.focus) { newwin.focus() }return false; } popup('" + url + "')</script>";

            if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("window.open"))
            {
                page.ClientScript.RegisterStartupScript(typeof(Popup), "RedirectTo", _script);
            }

        }
    }
}
